﻿using System;
using System.ComponentModel;
using System.Disposables;
using System.Linq.Expressions;
using SoftSource.Common;
using SoftSource.Timecard.ViewModelInterfaces;

namespace SoftSource.Timecard.ViewModels
{
    public class GetUserPasswordViewModel : IGetUserPasswordViewModel
    {
        #region Fields
        private CompositeDisposable compositeDisposable;
        #endregion Fields

        public GetUserPasswordViewModel()
        {
            this.compositeDisposable = new CompositeDisposable();
        }

        #region IGetUserPasswordViewModelConsume Members

        public Action OK
        {
            get { return () => this.OKSource.TryInvoke(this.Password); }
        }

        #endregion

        #region IGetUserPasswordViewModelService Members

        public Action<string> OKSource { get; set; }

        #endregion

        #region IGetUserPasswordViewModel Members

        private string password;
        public string Password
        {
            get { return this.password; }
            set
            {
                this.password = value;
                this.PropertyChanged.Notify(() => this.Password);
            }
        }

        public Action Cancel { get; set; }

        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            this.compositeDisposable.Dispose();
            GC.SuppressFinalize(this);
        }

        #endregion

        ~GetUserPasswordViewModel()
        {
            this.Dispose();
        }
    }
}
